package deepbitview

/**
 * simple utility class to access our key
 */
class ActiviationKeyHandler {

    /**
     * returns the users key for the deepbit site
     * @return
     */
    static String getDeepBitActivationKey() {
        return AccessKey.list().get(0).keyValue
    }

    /**
     * returns the sample rate in minutes
     * @return
     */
    static Integer getSampleRateInMinutes() {
        return 10
    }

    static boolean isKeyRegistered() {

        boolean valid = AccessKey.list().size() == 1

        if (AccessKey.list().size() > 1) {

            //for some reasons there were more than 1 key registered, which should never be the case
            AccessKey.list().each {AccessKey accessKey -> accessKey.delete(flush: true)}
        }

        return valid
    }
}
